/**
 * @Author lilinjie
 * @Description: 分类API
 */
import http from '@/utils/request'

// 获得分类
export const getAllCategory = ({ current: pageNum, pageSize }) => http({
  method: 'GET',
  url: `/admin/category/getCategoryList/${pageNum}/${pageSize}`
})

// 添加分类
export const addCategory = (data) => http({
  method: 'POST',
  url: `/admin/category/insertCategory`,
  data
})

// 删除分类
export const deleteCategory = (params) => http({
  method: 'GET',
  url: `/admin/category/deleteCategory`,
  params
})

// 更新分类
export const updateCategory = (data) => http({
  method: 'POST',
  url: `/admin/category/updateCategory`,
  data
})

// 按条件查询分类
export const searchCategory = ({ name, parentName, current: pageNum, pageSize }) => http({
  method: 'POST',
  url: `/admin/category/getCategoryListByQueryParam`,
  params: {
    pageNum,
    pageSize
  },
  data: {
    name,
    parentName,
  }
})
